<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        div {
            display: inline-block;
            height: 200px;
            background-color: pink;
            padding: 10px;
            border: 20px solid red;
        }
    </style>
</head>

<body>
    <div>21341414534534444343242</div>
    <script>
        const div = document.querySelector('div')
        /* div.clientWidth不包含border  */

        console.log(div.clientWidth);
        // resize 浏览器窗口大小发生改变时触发事件
        div.addEventListener('resize', function () {
            console.log(1);
        })
    </script>
</body>

</html>